package com.atguigu.patterns.composite;

import java.util.ArrayList;
import java.util.List;

public class ComponentComposite extends Component {

    List<Component> components = new ArrayList<>();

    public ComponentComposite(String name, String des) {
        super(name, des);
    }

    @Override
    protected void add(Component organizationComponent) {
        components.add(organizationComponent);
    }

    @Override
    protected void print() {
        System.out.println("--------------" + getName() + "--------------");
        //遍历 organizationComponents
        for (Component organizationComponent : components) {
            organizationComponent.print();
        }
    }
}
